﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace gChartSharp
{
    /// <summary>
    /// http://code.google.com/apis/chart/#scatter_plot
    /// </summary>
    public class ScatterPlotChart : ChartBase
    {
        /// <summary>
        /// 
        /// </summary>
        public override ChartType ChartType { get { return ChartType.s; } }


        #region Member Variables
        private ColorParam mColorParam;
        private SolidFillParam mSolidFillParam;
        private DataScaleParam mDataScaleParam;
        private LinearGradientFillParam mLinearGradientFillParam;
        private LinearStripesFillParam mLinearStripesFillParam;
        private TitleParam mTitleParam;
        private LegendParam mLegendParam;
        private AxisLabelParam mAxisLabelParam;
        private AxisLabelPositionParam mAxisLabelPositionParam;
        private AxisRangeParam mAxisRangeParam;
        private AxisStyleParam mAxisStyleParam;
        private AxisTypeParam mAxisTypeParam;
        #endregion


        #region Properties
        public ColorParam ColorParam 
        {
            get
            {
                if (mColorParam == null)
                    mColorParam = new ColorParam();

                return mColorParam;
            }
            set { mColorParam = value; }
        }


        public SolidFillParam SolidFillParam
        {
            get
            {
                if (mSolidFillParam == null)
                    mSolidFillParam = new SolidFillParam();

                return mSolidFillParam;
            }
            set { mSolidFillParam = value; }
        }


        public DataScaleParam DataScaleParam
        {
            get
            {
                if (mDataScaleParam == null)
                    mDataScaleParam = new DataScaleParam();

                return mDataScaleParam;
            }
            set { mDataScaleParam = value; }
        }


        public LinearGradientFillParam LinearGradientFillParam
        {
            get
            {
                if (mLinearGradientFillParam == null)
                    mLinearGradientFillParam = new LinearGradientFillParam();

                return mLinearGradientFillParam;
            }
            set { mLinearGradientFillParam = value; }
        }


        public LinearStripesFillParam LinearStripesFillParam
        {
            get
            {
                if (mLinearStripesFillParam == null)
                    mLinearStripesFillParam = new LinearStripesFillParam();

                return mLinearStripesFillParam;
            }
            set { mLinearStripesFillParam = value; }
        }


        public TitleParam TitleParam
        {
            get
            {
                if (mTitleParam == null)
                    mTitleParam = new TitleParam();

                return mTitleParam;
            }
            set { mTitleParam = value; }
        }


        public LegendParam LegendParam
        {
            get
            {
                if (mLegendParam == null)
                    mLegendParam = new LegendParam();

                return mLegendParam;
            }
            set { mLegendParam = value; }
        }


        public AxisLabelParam AxisLabelParam
        {
            get
            {
                if (mAxisLabelParam == null)
                    mAxisLabelParam = new AxisLabelParam();

                return mAxisLabelParam;
            }
            set { mAxisLabelParam = value; }
        }


        public AxisLabelPositionParam AxisLabelPositionParam
        {
            get
            {
                if (mAxisLabelPositionParam == null)
                    mAxisLabelPositionParam = new AxisLabelPositionParam();

                return mAxisLabelPositionParam;
            }
            set { mAxisLabelPositionParam = value; }
        }


        public AxisRangeParam AxisRangeParam
        {
            get
            {
                if (mAxisRangeParam == null)
                    mAxisRangeParam = new AxisRangeParam();

                return mAxisRangeParam;
            }
            set { mAxisRangeParam = value; }
        }


        public AxisStyleParam AxisStyleParam
        {
            get
            {
                if (mAxisStyleParam == null)
                    mAxisStyleParam = new AxisStyleParam();

                return mAxisStyleParam;
            }
            set { mAxisStyleParam = value; }
        }


        public AxisTypeParam AxisTypeParam
        {
            get
            {
                if (mAxisTypeParam == null)
                    mAxisTypeParam = new AxisTypeParam();

                return mAxisTypeParam;
            }
            set { mAxisTypeParam = value; }
        }
        #endregion


        public ScatterPlotChart(int width, int height) 
            : base(width, height) { }

        public ScatterPlotChart(int width, int height, EncodingType encType) 
            : base(width, height, encType) { }

        public ScatterPlotChart(int width, int height, float[] dataSet) 
            : base(width, height, dataSet) { }

        public ScatterPlotChart(int width, int height, EncodingType encType, float[] dataSet)
            : base(width, height, encType, dataSet) { }


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string GetURL()
        {
            if (this.Data.DataSets.Count() < 2)
                throw new ChartException("Scatter plots must contain 2 data sets.");

            StringBuilder sb = CreateBaseURL();
            base.RenderIChartParam(mColorParam, ref sb);
            base.RenderIChartParam(mSolidFillParam, ref sb);
            base.RenderIChartParam(mDataScaleParam, ref sb);
            base.RenderIChartParam(mLinearGradientFillParam, ref sb);
            base.RenderIChartParam(mLinearStripesFillParam, ref sb);
            base.RenderIChartParam(mTitleParam, ref sb);
            base.RenderIChartParam(mLegendParam, ref sb);
            base.RenderIChartParam(mAxisLabelParam, ref sb);
            base.RenderIChartParam(mAxisLabelPositionParam, ref sb);
            base.RenderIChartParam(mAxisRangeParam, ref sb);
            base.RenderIChartParam(mAxisStyleParam, ref sb);
            base.RenderIChartParam(mAxisTypeParam, ref sb);
            return sb.ToString();
        }


        public override string GetHTML()
        {
            return "";
        }
    }
}
